/**
 * @class   wosh::communication::VoiceCall
 * @brief   wosh::Notification representing an voice call (based on audio-file).
 *
 *
 ****************************************************************************
 * @version $Id: VoiceCall.h 2863 2010-08-07 04:28:58Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Communication_VoiceCall_H__
 #define __WOSH_Communication_VoiceCall_H__

 #include <woshDefs.h>
 #include <core/Notification.h>


namespace wosh {
 namespace communication {

class VoiceCall : public Notification
 {
	WOSH_SERIALIZABLE(wosh::communication::VoiceCall)
	WOSH_COMPARE_RTTI(wosh::communication::VoiceCall)

	public:
		/**
		 * @brief   call type
		 */
		enum CALL_TYPE {
			CALL_UNKNOWN_TYPE	= 0x00,
			CALL_INCOMING		= 0x01,
			CALL_OUTGOING		= 0x02
		};
		/**
		 * @brief   states of a call
		 */
		enum CALL_STATUS {
			STATUS_UNKNOWN		= 0x00,
			STATUS_IDLE			= 0x01,
			STATUS_DIALING		= 0x02,
			STATUS_RINGING		= 0x04,
			STATUS_CONNECTED	= 0x08,
			STATUS_DISCONNECTED	= 0x10
		};

	public:
		/**
		 * @brief  Empty constructor.
		 */
		VoiceCall();
		/**
		 * @brief  Copy constructor.
		 * @param m [in] the source object to be copied
		 */
		VoiceCall( const VoiceCall& m );
		/**
		 * @brief  Empty destructor.
		 */
		virtual ~VoiceCall() { }

	public:

		virtual const std::string& getBrief() const				{ return this->textmessage; }
		virtual const std::string& getPlain() const				{ return this->textmessage; }

		virtual std::string getSummary( int maxsize = 1023 ) const
																{ (void)maxsize; return this->textmessage; }

		virtual void setBrief( const std::string& value )		{ this->textmessage = value; }
		virtual void setPlain( const std::string& value )		{ this->textmessage = value; }

//@}
/** @name Setters
 * @{
 ******************************************************************************/
	public:

		void setDuration( int seconds )					{ this->duration = seconds; }

		void setCallType( CALL_TYPE ph_type )			{ this->callType = ph_type; }

		void setCallStatus( CALL_STATUS ph_status )		{ this->callStatus = ph_status; }

		void setIdle()									{ this->callStatus = VoiceCall::STATUS_IDLE; }
		void setDialing()								{ this->callStatus = VoiceCall::STATUS_DIALING; }
		void setRinging()								{ this->callStatus = VoiceCall::STATUS_RINGING; }
		void setConnected()								{ this->callStatus = VoiceCall::STATUS_CONNECTED; }
		void setDisconnected()							{ this->callStatus = VoiceCall::STATUS_DISCONNECTED; }

		void setIncomingCall()							{ this->callType = VoiceCall::CALL_INCOMING; }
		void setOutgoingCall()							{ this->callType = VoiceCall::CALL_OUTGOING; }

		virtual void clear();

//@}
/** @name Getters
 * @{
 ******************************************************************************/
	public:

		int getDuration() const							{ return this->duration; }

		VoiceCall::CALL_TYPE getCallType() const		{ return this->callType; }
		VoiceCall::CALL_STATUS getCallStatus() const	{ return this->callStatus; }

		bool isIncomingCall() const						{ return (this->callType == VoiceCall::CALL_INCOMING); }
		bool isOutgoingCall() const						{ return (this->callType == VoiceCall::CALL_OUTGOING); }

		virtual std::string getCallSummary() const;

		static VoiceCall::CALL_TYPE getCallTypeFromString( const std::string& type );
		static VoiceCall::CALL_STATUS getCallStatusFromString( const std::string& status );

		inline std::string getCallTypeAsString() const {
			return getCallTypeAsString(this->callType);
		 }
		inline std::string getCallStatusAsString() const {
			return getCallStatusAsString(this->callStatus);
		 }

		static std::string getCallTypeAsString( VoiceCall::CALL_TYPE type );
		static std::string getCallStatusAsString( VoiceCall::CALL_STATUS status );

		virtual Notification::TYPE getNotificationType() const	{ return Notification::TYPE_AUDIO; }

//@}
/** @name Operators Overloading
 * @{
 ******************************************************************************/
	public:
		virtual VoiceCall& operator=(const VoiceCall& m);

		virtual bool operator==(const VoiceCall &other) const;
		virtual bool operator!=(const VoiceCall &other) const { return !(*this == other);  }

//@}
/** @name Serialization interface
 * @{
 ******************************************************************************/
	public:
		virtual std::string toString() const;
		virtual bool updateHash( DataHashContext* hash_context ) const;
//@}
	protected:
		long duration;				///< elapsed time in second

		CALL_STATUS callStatus;
		CALL_TYPE callType;

		std::string textmessage;


}; // class def

 }; // namespace communication
}; // namespace wosh

#endif //__WOSH_Communication_VoiceCall_H__
